#include "app_message.h"
#include <stdio.h>
#include <assert.h>
#include <string.h>

static unsigned char msg[] = {
    0x01,
    0x02,
    0x03,
    0xA1,
    0xB1,
    0xC1,
    0xD1,
    0xE1,
};

int main(void)
{
    char json_str[1024];
    message *message = app_message_initFromBinary(msg, sizeof(msg));
    app_message_saveAsJson(message, json_str, sizeof(json_str));
    printf("%s\n", json_str);
    app_message_free(message);

    message = app_message_initFromJson(json_str, sizeof(json_str));
    app_message_saveAsBinary(message, json_str, sizeof(json_str));
    assert(memcmp(json_str, msg, sizeof(msg)) == 0);
    app_message_free(message);
    return 0;
}
